<template>
  <view>
    <image
      src="https://tzdj.1qit.com/assets/wx_imgs/my/bg2.png"
      class="w-750 h-415"
    ></image>
    <view class="content w-750 p-l-45 p-r-45">
      <info
        :src="info.src"
        :username="info.username"
        :phone="info.phone"
      ></info>
      <view class="ml p-l-35 c_bai">
        <text class="text">我的邀请码:</text>
        <text>{{ invitecode }}</text>
        <!-- 一键复制 -->
        <text class="copybtn" @click="copyBtn()">复制</text>
      </view>
      <!-- <btns></btns> -->
      <util :list="list" @jump="jump"></util>
    </view>
    <carBottoms :type3="false" v-if="!identity"></carBottoms>
    <tabBar :type3="false" v-else></tabBar>
  </view>
</template>

<script>
import info from "./componetns/info.vue";
import btns from "./componetns/btns.vue";
import util from "./componetns/utils.vue";
export default {
  components: {
    info,
    btns,
    util,
  },
  mounted() {
    this.identity = uni.getStorageSync("identity");
  },
  data() {
    return {
      invitecode: "",
      identity: "",
      list: [
        {
          icon: "https://tzdj.1qit.com/assets/wx_imgs/my/01.png",
          title: "资金明细",
        },
        {
          icon: "https://tzdj.1qit.com/assets/wx_imgs/my/02.png",
          title: "常见问题",
          path: "/pages/app/questions/index",
        },
        {
          icon: "https://tzdj.1qit.com/assets/wx_imgs/my/03.png",
          title: "免责声明",
          path: "/pages/app/statement/index",
        },
        {
          icon: "https://tzdj.1qit.com/assets/wx_imgs/my/icon6.png",
          title: "切换身份",
          path: "/pages/index/index",
        },
        {
          // 分销
          icon: "https://tzdj.1qit.com/assets/wx_imgs/my/fenxiao.png",
          title: "分销中心",
          path: "/pages/app/distribution/index",
        },
        {
          // 填写邀请码
          icon: "https://tzdj.1qit.com/assets/wx_imgs/my/yaoqingma.png",
          title: "填写邀请码",
          path: "/pages/app/inviteCode/index",
        },
        {
          // 银行卡绑定
          icon: "https://tzdj.1qit.com/assets/wx_imgs/my/yinhangka.png",
          title: "银行卡绑定",
          path: "/pages/app/cardBind/index",
        },
      ],
      info: {
        src: "https://tzdj.1qit.com/assets/wx_imgs/my/04.png",
        username: "用户名",
        phone: "手机号",
      },
    };
  },
  onLoad() {
    this.info.src = this.$store.state.info.avatar;
    this.info.username = this.$store.state.info.nickname;
    this.info.phone =
      this.$store.state.info.mobile.substr(0, 3) +
      "****" +
      this.$store.state.info.mobile.substr(7);
    console.log(this.$store.state.info);
  },
  methods: {
    // 一键复制
    copyBtn() {
      uni.setClipboardData({
        data: this.invitecode,
        success: function () {
          uni.showToast({
            title: "复制成功",
          });
        },
        fail: function () {
          uni.showToast({
            title: "复制失败",
          });
        },
      });
    },

    jump(path) {
      uni.navigateTo({
        url: path,
      });
    },
  },
  mounted() {
    uni.request({
      url: "http://jjdj.hongliwangluo.com/api/common/userinfo",
      header: {
        token: uni.getStorageSync("token"),
      },
      success: (res) => {
        console.log(res.data.data.invitation_code);
        this.invitecode = res.data.data.invitation_code;
      },
    });
  },
};
</script>

<style lang="scss">
.content {
  position: absolute;
  top: var(--status-bar-height);
  left: 0;
}
.ml {
  margin-left: 120rpx;
}
.text {
  margin-right: 10rpx;
}
.copybtn {
  margin-left: 20rpx;
}
</style>
